﻿using Data0426.Base.Dommain;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Data0426.Base.Infrastructure
{
    public class BaseRequest<T> : IBaseRequest<T> where T : BaseEntity
    {
        private readonly MyContext context;

        public BaseRequest(MyContext context)
        {
            this.context = context;
        }

        public int Create(T t)
        {
            context.Set<T>().Add(t);
            return context.SaveChanges();
        }

        public IQueryable<T> GetAll()
        {
            return context.Set<T>();
        }

        public int Update(T t)
        {
            context.Set<T>().Update(t);
            return context.SaveChanges();
        }
    }
}
